<template>
<!--发起节点-->
  <promoter v-if="nodeConfig.type == 0" v-model="nodeConfig" :class="this.nodeConfig.designForNode? 'isDisabled':''"></promoter>
<!--审核节点-->
  <approver v-if="nodeConfig.type == 1" v-model="nodeConfig" :class="this.nodeConfig.designForNode? 'isDisabled':''"></approver>
<!--抄送节点-->
  <send v-if="nodeConfig.type == 2" v-model="nodeConfig" :class="this.nodeConfig.designForNode? 'isDisabled':''"></send>
<!--路由节点-->
  <branch v-if="nodeConfig.type == 4" v-model="nodeConfig">
    <template v-slot="slot">
      <node-wrap v-if="slot.node" v-model="slot.node.childNode"></node-wrap>
    </template>
  </branch>

  <node-wrap v-if="nodeConfig.childNode" v-model="nodeConfig.childNode"></node-wrap>
</template>

<script>
import approver from "./nodes/approver.vue";
import promoter from "./nodes/promoter.vue";
import branch from "./nodes/branch.vue";
import send from "./nodes/send.vue";

export default {
  props: {
    modelValue: { type: Object, default: () => {} },
  },
  components: {
    approver,
    promoter,
    branch,
    send,
  },
  data() {
    return {
      nodeConfig: {},
    };
  },
  watch: {
    modelValue(val) {
      this.nodeConfig = val;
    },
    nodeConfig(val) {
      this.$emit("update:modelValue", val);
    },
  },
  mounted() {
    this.nodeConfig = this.modelValue;
    console.log(this.nodeConfig)
  },
  methods: {},
};
</script>

<style scoped lang="less">
.isDisabled {
  pointer-events: none;
  cursor: default;
}
</style>
